﻿<Window x:Class="Sales.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:l="clr-namespace:Sales"
        Title="売上管理" Height="550" Width="900" ResizeMode="CanMinimize">
    <Window.DataContext>
        <l:MainWindowViewModel/>
    </Window.DataContext>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="35"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="35"/>
        </Grid.RowDefinitions>
        <StackPanel Grid.Row="0" HorizontalAlignment="Left">
            <ComboBox Margin="4" Width="60" 
                      ItemsSource="{x:Static l:Years.Items}" 
                      SelectedItem="{Binding Path=Year}">
                <ComboBox.ItemsPanel>
                    <ItemsPanelTemplate>
                        <StackPanel HorizontalAlignment ="Right" Orientation="Vertical"/>
                    </ItemsPanelTemplate>
                </ComboBox.ItemsPanel>    
            </ComboBox>
            <TextBlock Margin="4" Text="年度"/>
            <ComboBox Margin="4" Width="200" ItemsSource="{x:Static l:Sections.Items}" SelectedItem="{Binding Path=Section}">
                <ComboBox.ItemsPanel>
                    <ItemsPanelTemplate>
                        <StackPanel HorizontalAlignment ="Left" Orientation="Vertical"/>
                    </ItemsPanelTemplate>
                </ComboBox.ItemsPanel>
            </ComboBox>
            <Button Margin="4" Content="読み込み" Command="{Binding Path=ReadCommand}"/>
        </StackPanel>
        <DataGrid Grid.Row="1" 
                  Margin="4" 
                  AutoGenerateColumns="False" 
                  IsReadOnly="True" 
                  IsSynchronizedWithCurrentItem="True" 
                  ItemsSource="{Binding Path=Items,Mode=OneWay}" 
                  SelectedItem="{Binding Path=Item}"
                  SelectionMode="Single">
            <DataGrid.Columns>
                <DataGridTextColumn 
                    Width="60" 
                    Header="月" 
                    ElementStyle="{StaticResource CellStyle}"
                    Binding="{Binding Path=Month}"/>
                <DataGridTextColumn 
                    Width="120*" 
                    Header="目標額" 
                    ElementStyle="{StaticResource CellStyle}"
                    Binding="{Binding Path=PlanPrice,StringFormat=##\,###\,###}"/>
                <DataGridTextColumn 
                    Width="120*" 
                    Header="実績額" 
                    ElementStyle="{StaticResource CellStyle}"
                    Binding="{Binding Path=ResultPrice,StringFormat=##\,###\,###}"/>
                <DataGridTextColumn 
                    Width="120*" 
                    Header="差額" 
                    ElementStyle="{StaticResource CellStyle}"
                    Binding="{Binding Path=SubtractPrice,StringFormat=##\,###\,###}"/>
                <DataGridTextColumn 
                    Width="120*" 
                    Header="差額合計" 
                    ElementStyle="{StaticResource CellStyle}"
                    Binding="{Binding Path=TotalPrice,StringFormat=##\,###\,###}"/>
            </DataGrid.Columns>
        </DataGrid>
        <StackPanel Grid.Row="2">
            <Button Command="{Binding Path=ListCommand}" 
                    Content="一覧..."/>
            <Button Command="{Binding Path=PrintCommand}" 
                Content="印刷..."/>
            <Button Command="{Binding Path=ImportCommand}" 
                Content="インポート..."/>
            <Button Command="{Binding Path=ExportCommand}" 
                Content="エクスポート..."/>
            <Button 
                Content="閉じる" Click="Button_Click"/>
            <TextBlock Width="32"/>
            <Button Command="{Binding Path=AboutCommand}"
                Content="ヘルプ"/>
            <Button Content="バージョン情報..."/>
        </StackPanel>
    </Grid>
</Window>
